{
Function:       _T3 (simple function, Periods may vary)

Description:    The T3 Average is essentially a low-pass filter, as are the
                traditional moving average and exponential moving average.  The T3
                Average, however, exhibits a steeper rolloff, resulting in better
                filtering of high-frequency noise while better preserving the
                low-frequency components of a time series.

                This function is an EasyLanguage version of the algorithm described
                in the January 1998 issue of TASC, p57, "Smoothing Techniques for
                More Accurate Signals" by Tim Tillson.  It is translated from
                the MetaStock code presented in the article.  The function allows
                a variable length as input.

                The variable b (also called "Hot") is a damping coefficient.  The
                suggested value of b is 0.7, but this value slightly amplifies
                low-frequency components. b=0.5 seems better for having a flat
                response at low frequencies.  A smaller value of b will result in
                too much attenuation of low frequencies, according to Alex Matuluch (4/2003).

                See:   http://unicorn.us.com/trading.src._T3Average.txt
                
Notes:			Periods (length) may vary between calls.                

Author:         MarkSanDiego    (original source: Bob Fulks)

Updated:        09/08/10                
}

inputs:     
    Price(NumericSeries), 
    Periods(NumericSimple);

vars:   
    Hot(0.7),
    b(Hot), 
    b2(b * b), 
    b3(b * b * b), 
    e1(Price), 
    e2(Price), 
    e3(Price), 
    e4(Price), 
    e5(Price), 
    e6(Price), 
    c1(-b3), 
    c2(3 * b2 + 3 * b3), 
    c3(-6 * b2 - 3 * b - 3 * b3),   
    c4(1 + 3 * b + b3 + 3 * b2), 
    f1(0), 
    f2(0); 



    f1 = 2 / (Periods + 1);
    f2 = 1 - f1;

    e1 = f1 * Price + f2 * e1;
    e2 = f1 * e1 + f2 * e2;
    e3 = f1 * e2 + f2 * e3;
    e4 = f1 * e3 + f2 * e4;
    e5 = f1 * e4 + f2 * e5;
    e6 = f1 * e5 + f2 * e6;


    _T3 = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3;


